<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
	<title>HouDun许愿墙</title>
	<link rel="stylesheet" href="__PUBLIC__/Css/index.css" />
	<script type="text/javascript" src='__PUBLIC__/Js/jquery-1.7.2.min.js'></script>
	<script type="text/javascript" src='__PUBLIC__/Js/index.js'></script>
</head>
<body>
	<div id='top'>
		<span id='send'></span>
	</div>
	<div id='main'>
            <volist name='wishlist' id='vo' empty="$empty">
		<dl class='paper a{$vo["color"]}'>
			<dt>
				<span class='username'>{$vo["username"]}</span>
				<span class='num'>NO.{$vo["id"]}</span>
			</dt>
			<dd class='content'>{$vo["content"] | phiz_replace }</dd>
			<dd class='bottom'>
				<span class='time'>{:date('Y-m-d h:i',$vo['time_at'])}</span>
				<a href="" class='close'></a>
			</dd>
		</dl>
            </volist>
	</div>

	<div id='send-form'>
		<p class='title'><span>许下你的愿望</span><a href="" id='close'></a></p>
                <form  name='wish'>
			<p>
				<label for="username">昵称：</label>
				<input type="text" name='username' id='username'/>
			</p>
			<p>
				<label for="content">愿望：(您还可以输入&nbsp;<span id='font-num'>50</span>&nbsp;个字)</label>
				<textarea name="content" id='content'></textarea>
				<div id='phiz'>
					<img src="__PUBLIC__/Images/phiz/zhuakuang.gif" alt="抓狂" />
					<img src="__PUBLIC__/Images/phiz/baobao.gif" alt="抱抱" />
					<img src="__PUBLIC__/Images/phiz/haixiu.gif" alt="害羞" />
					<img src="__PUBLIC__/Images/phiz/ku.gif" alt="酷" />
					<img src="__PUBLIC__/Images/phiz/xixi.gif" alt="嘻嘻" />
					<img src="__PUBLIC__/Images/phiz/taikaixin.gif" alt="太开心" />
					<img src="__PUBLIC__/Images/phiz/touxiao.gif" alt="偷笑" />
					<img src="__PUBLIC__/Images/phiz/qian.gif" alt="钱" />
					<img src="__PUBLIC__/Images/phiz/huaxin.gif" alt="花心" />
					<img src="__PUBLIC__/Images/phiz/jiyan.gif" alt="挤眼" />
				</div>
			</p>
			<span id='send-btn'></span>
                        <!--<input id='input-btn' type='submit' value='发布愿望'></input>-->
		</form>
	</div>
<!--[if IE 6]>
    <script type="text/javascript" src="./Js/iepng.js"></script>
    <script type="text/javascript">
        DD_belatedPNG.fix('#send,#close,.close','background');
    </script>
<![endif]-->
<script type="text/javascript">
$(document).ready(function(){
    //调试$("send-bt")是否使用
    //console.log($('send-bt'))
    
    $("#send-btn").click(function(){
        //URL地址
        URL = '{:U("test")}';
        //获取用户名和内容
        username = $("input[name='username']");//表单里的input元素中的name='username'
        content = $("#content");//表单里id=content
        /*
       if(username.val() ==''){
          alert("用户名不能为空!");
           username.focus();
            return false;
        }
      if(content.val() == ''){
            alert("留言板不能为空!");
            content.focus();
            return false;
        }
       */
        //ajax获取
        $.post(URL,{user:username.val(),content:content.val()},
        function(data){
            //console.log(data);
           // data = eval('(' + data + ')');
           console.log(data);
            //console.log(data.content);
            wish = "";
            wish += '<dl class="paper a' + data.color + '">';
            wish += "<dt><span class='username'>"+ data.username +"</span>";
            wish += "<span class='num'>NO."+ data.id+"</span>";
            wish += "</dt><dd class='content'>"+ data.content+"</dd>";
            wish += "<dd class='bottom'><span class='time'>"+ data.time_at+"</span>";
            wish += "<a href='' class='close'></a></dd></dl>";
            
            $('#main').append(wish);
            
            $('#close').click();
        });
    });
});

</script>


</body>
</html>